package com.wn;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import feign.Logger;
import feign.Retryer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author yellow Docter
 * @date 2023 -02-21
 * @desc
 *
 *   1、 @EnableFeignClients开启注解后    加载 @Import(FeignClientsRegistrar.class) 类
 *      把 @FeignClient 标记的接口注入到ioc容器中
 *
 *
 */
@EnableSwagger2WebMvc
@EnableKnife4j
@EnableFeignClients
@SpringBootApplication
public class UserConsumerApplication {
    public static void main(String[] args) {
        SpringApplication.run(UserConsumerApplication.class,args);
    }

    //在启动类或配置类中注入负载均衡策略对象。所有服务请求均使用该策略。
    // 配置 负载均衡的规则
    @Bean
    public IRule rules(){
        return new RandomRule();
    }

    //开启日志
    @Bean
    public Logger.Level loggerLevel(){
        return Logger.Level.FULL;
    }

    @Bean
    public Retryer feignRetryer() {
        return new Retryer.Default();
    }
}
